<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Portfolio extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->model('portfolio_model');
    }

    public function index() {
        $data['title'] = 'Portfolio';
        $data['path'] = base_url() . 'assets';
        $data['por_img_path'] = base_url() . 'upload/images/portfolio/';
        $data['por_array'] = $this->portfolio_model->get_portfolio();
        $data['cat_array'] = $this->portfolio_model->get_category();

        $this->load->view('include/header', $data);
        $this->load->view('portfolio/index', $data);
        $this->load->view('include/footer', $data);
    }

    public function detail($slug = FALSE) {
        if (empty($slug)) {
            redirect('portfolio/index');
        } else {
            $item = $this->portfolio_model->get_portfolio($slug);
            $data['item'] = $item[0];
            if (empty($data['item'])) {
                redirect('portfolio/index');
            }
            $data['title'] = 'Portfolio Detail';
            $data['path'] = base_url() . 'assets';
            $data['por_img_path'] = base_url() . 'upload/images/portfolio/';
            $data['latest_portfolio'] = $this->portfolio_model->get_latest_portfolio(4);

            $this->load->view('include/header', $data);
            $this->load->view('portfolio/detail', $data);
            $this->load->view('include/footer', $data);
        }
    }

}
